package com.lzq.streamdemo.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

public class StreamFinalMethod {
    public static void main(String[] args) {
        //forEach 遍历

        //count 计数
        List<Integer> list = new ArrayList<>();
        Collections.addAll(list,1,2,3,4,5,6,7,8,9,10);
        System.out.println(list.stream().count());

        //toArray 转为数组
        List<Integer> list2 = new ArrayList<>();
        Collections.addAll(list2,1,2,3,4,5,6,7,8,9,10);
        Object[] array = list2.stream().toArray();
        for (Object num : array) {
            System.out.println(num);
        }
        String[] array1 = list2.stream().toArray(value -> new String[value]);
        //collect 收集
        Integer[] arr = {1,2,3,4,5,6};
        Arrays.stream(arr).map(num->num+1).collect(Collectors.toList());
    }
}
